﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ClockControl.Clock
{
    public partial class Clock : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string blackArrowID = this.ID + '_' + this.ImageBlackArrow.ID;
            this.buttonRotateBlackArrow.Attributes["onclick"] = "Rotate('" + blackArrowID + "', 123)";

            Response.Write("<script>" +
                "function StartRotatingArrows() " +
                "{ " + 
                    "var blackArrowImage = document.getElementById(blackArrowID); " +
                    "if (blackArrowImage == null) " +
                    "{ " +
                        " alert(null); " +
                        " alert(blackArrowID); " +
                        "setTimeout(StartRotatingArrows, 1000); " +
                    "} " + 
                    "else " +
                    "{" +
                        "RecursivelyRotateArrows(blackArrowID);" +
                    "}" + 
                "}" +                
                "var blackArrowID = '" + blackArrowID + "'; " +
                "StartRotatingArrows();" +
                "</script>");           
            
        }
    }
}